<html>
<head><meta charset="utf-8"><title>inline-as-an-error · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html">inline-as-an-error</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="174843752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174843752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174843752">(Sep 04 2019 at 01:18)</a>:</h4>
<blockquote>
<p>One thing we identified is that we may want #[inline] to be an error (though I see in the doc that @centril maybe doesn't agree). In short because it's not really clear what it should mean, and right now it doesn't do much.</p>
</blockquote>
<p>I do disagree; <code>#[inline]</code> is a hint and it 1) doesn't have to do anything at all, 2) can have its meaning changed whenever we want</p>



<a name="174843761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174843761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174843761">(Sep 04 2019 at 01:18)</a>:</h4>
<p>but I think we should not introduce contextual static semantics for it</p>



<a name="174914422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174914422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174914422">(Sep 04 2019 at 19:27)</a>:</h4>
<p>I agree that it's just a hint. The main reason to make it an error would be to eliminate bug reports and avoid confusion, since it has no real role in this position. I don't really care strongly enough to argue about it though. We could just close the bug as "wontfix"</p>



<a name="174914461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174914461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174914461">(Sep 04 2019 at 19:27)</a>:</h4>
<p>That said, the definition of the <code>#[inline]</code> attribute presumably already has some rules about what sorts of items it can be applied to</p>



<a name="174914555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174914555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174914555">(Sep 04 2019 at 19:28)</a>:</h4>
<p>It doesn't seem unreasonable for those rules to exclude <code>async fn</code>, just as they exclude (say) structs:</p>
<div class="codehilite"><pre><span></span><span class="cp">#[inline]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=6428fab64bfb8c45411c5acf4418a5c3" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=6428fab64bfb8c45411c5acf4418a5c3">gives an error</a></p>



<a name="174941281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174941281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174941281">(Sep 05 2019 at 03:16)</a>:</h4>
<p>I think <code>struct</code> and <code>async fn</code> are dissimilar. The error message says it cannot be applied to a function, but an <code>async fn</code> is a function. Indeed, with the desugaring based explanation of <code>async fn</code>, it does seem reasonable for <code>#[inline]</code> to essentially transfer to the desugared function. Whether it then has an effect or not is merely a quality-of-implementation issue.</p>
<p>I would be fine with a lint or something if this becomes a frequent source of reports but I am not convinced it will be.</p>



<a name="174979840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174979840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174979840">(Sep 05 2019 at 14:38)</a>:</h4>
<p>In some sense an async fn is just a struct declaration though? Like, that's what happens when it's called</p>



<a name="174997764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174997764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174997764">(Sep 05 2019 at 17:41)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span>  that's the ~output of calling the <code>async fn</code> but it's still a function to be called</p>



<a name="174997825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174997825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174997825">(Sep 05 2019 at 17:42)</a>:</h4>
<p><code>async fn</code>s happen to be pure and all</p>



<a name="174997833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174997833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174997833">(Sep 05 2019 at 17:42)</a>:</h4>
<p>hm, I guess that's true. Presumably then <code>#[inline]</code> will work similarly to inlining a constructor function</p>



<a name="174997886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174997886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174997886">(Sep 05 2019 at 17:42)</a>:</h4>
<p>yea I think that's a good way to think of it</p>



<a name="174997887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/inline-as-an-error/near/174997887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/inline-as-an-error.html#174997887">(Sep 05 2019 at 17:42)</a>:</h4>
<p>(there is, I suppose, some parallel with asking for <code>#[inline]</code> on a tuple struct for which we generate <code>fn Type(...)</code>)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>